#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
AC_INIT([gamebrowser], [0.1], [marcelo@bezerra.org])
AM_INIT_AUTOMAKE([-Wall -Werror])
#AC_CONFIG_SRCDIR([db.c])
AC_CONFIG_HEADER([config.h])

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC

# Checks for libraries.
AX_LIB_MYSQL()

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h unistd.h sys/select.h cgi.h pthread.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_TYPE_INT32_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_TYPE_UINT32_T

# Checks for library functions.
AC_FUNC_ERROR_AT_LINE
AC_FUNC_MEMCMP
AC_FUNC_SELECT_ARGTYPES
AC_CHECK_FUNCS([memset select socket strcasecmp strchr strerror gethostbyname_r strndup])


AC_CXX_TEMPLATES()
dnl AC_CXX_TEMPLATE_QUALIFIED_BASE_CLASS()
AC_CXX_REINTERPRET_CAST()
AC_CXX_STATIC_CAST()
AC_CXX_NAMESPACES()
AC_CXX_HAVE_STD()
AC_CXX_HAVE_STL()
AC_CXX_COMPILER_VENDOR([COMPILER_VENDOR])


AC_CHECK_LIB([xml2], [xmlInitParser])
AC_CHECK_LIB([GeoIP], [GeoIP_open])
AC_CHECK_LIB([mysqlclient_r], [mysql_init])
AC_CHECK_LIB([cgi], [cgiHeader])
AC_CHECK_LIB([pthread], [pthread_mutex_lock])
AC_CHECK_LIB([curl], [curl_global_init])

AC_LANG_PUSH(C++)
AX_CXX_CHECK_LIB(cgicc, [cgicc::HTTPCookie])
AX_CXX_CHECK_LIB(cgicc, [cgicc::Cgicc::getVersion () const])
AC_LANG_POP(C++)

PKG_CHECK_MODULES(GLIB, glib-2.0)
PKG_CHECK_MODULES(GTHREAD, gthread-2.0)
PKG_CHECK_MODULES(XML2, libxml-2.0)

CFLAGS="$CFLAGS $XMLSEC_CFLAGS"
CXXFLAGS="$CXXFLAGS $XMLSEC_CFLAGS"
CPPFLAGS="$CPPFLAGS $XMLSEC_CFLAGS"
LDFLAGS="$LDFLAGS $XMLSEC_LIBS"

AC_CONFIG_FILES([Makefile tests/Makefile])
AC_OUTPUT
